import { Component, OnInit, ViewChild } from '@angular/core';
import { _HttpClient, ModalHelper } from '@delon/theme';
import { STColumn, STComponent } from '@delon/abc';
import { SFSchema } from '@delon/form';
import { NzMessageService, NzModalService } from 'ng-zorro-antd';
@Component({
  selector: 'cost-account',
  templateUrl: './account.component.html',
  styles: [`
    .header-info {
      color: #f5222d;
    }
  `]
})
export class CostAccountComponent {
  queryStr: any = {
    offset: 0,
    limit: 10
  };
  loading = false;
  account: any;
  data: any[] = [];
  searchSchema: SFSchema = {
    properties: {
      no: {
        type: 'string',
        title: '标题'
      }
    }
  };
  @ViewChild('st') st: STComponent;
  columns: STColumn[] = [
    { title: '标题', index: 'title' },
    { title: '类型', index: 'type' },
    { title: '金额', index: 'money' },
    { title: '状态', index: 'status' },
    { title: '去向', index: 'opposite' },
    { title: '备注', index: 'remark' },
    { title: '时间', index: 'createAt' }
  ];
  constructor(
    private http: _HttpClient,
    public msg: NzMessageService
  ) { }
  ngOnInit() {
    this.getData();
  }
  getData() {
    this.loading = true;
    this.http.get('api/account/list', this.queryStr).subscribe((res: any) => {
      this.account = res[0];
    });
    this.http.get('api/records/list', this.queryStr).subscribe((res: any) => {
      this.data = res.objects;
      this.loading = false;
    });
  }
}
